#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" 
@author:zhangxing 
@file: product.py 
@time: 2021/06/27 
"""
import pandas as pd


class Product:
    def __init__(self, product_name):
        self.product_name = product_name
        self.blocks_excel = 'D:\\PycharmProjects\\djangowithvue\\product\\src\\blocks.xls'

    def get_blocks_info(self):
        df = pd.read_excel(self.blocks_excel, sheet_name=None)
        print(list(df.keys()))
        blocks = []
        layer_group = list(df.keys())
        for layer in layer_group:
            print(df[layer])
        ret = {
            'blocks': [],
            'layer_group': layer_group,
            'net_group': []
        }

    def get_block_info(self, block_name):
        df = pd.read_excel(self.blocks_excel, sheet_name=block_name)
        rect = df.values.tolist()
        layer_group = list(set([r[4] for r in rect]))
        layer_group.sort()
        net_group = list(set([r[5] for r in rect]))
        ret = {
            'block_name': block_name,
            'rect': rect,
            'layer_group': layer_group,
            'net_group': net_group
        }
        print(ret)
        return ret


if __name__ == '__main__':
    p = Product()
    p.get_block_info('block1')
